import java.awt.Color;
import java.awt.Cursor;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import javax.swing.*;



import javax.swing.JPanel;

public class addProject extends JPanel implements MouseListener, MouseMotionListener{
	private static int x, y;
	private Connection connect;
	private Image background, save, cancel;
	private int goNext=0;
	private JTextField pname, budget, fengshui;
	private JComboBox startMo, startDay, startYr, endMo, endDay, endYr, status;
	private static String[] smon={"Month: ", "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
		"Sep","Oct","Nov","Dec"};
	private static String[] sday={"Day: ","01","02","03","04","05","06","07","08","09","10","11","12","13",
		"14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29",
		"30","31"};
	private static String[] syr={"Year: ","2012","2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998","1997","1996","1995","1994"};
	private static String[] emon={"Month: ", "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
		"Sep","Oct","Nov","Dec"};
	private static String[] eday={"Day: ","01","02","03","04","05","06","07","08","09","10","11","12","13",
		"14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29",
		"30","31"};
	private static String[] eyr={"Year: ","2012","2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998","1997","1996","1995","1994"};
	private static String[] stat={"on-going", "on-hold", "cancelled"};
		 
	 public addProject(){
		 loadImages();
		 

			pname = new JTextField(50);
			startMo = new JComboBox(smon);
			startDay = new JComboBox(sday);
			startYr = new JComboBox(syr);
			endMo = new JComboBox(emon);
			endDay = new JComboBox(eday);
			endYr = new JComboBox(eyr);
			budget = new JTextField(50);
			status = new JComboBox(stat);
			fengshui = new JTextField(300);
			
			setLayout(null);
			pname.setBounds(460,215,300,30);
			startMo.setBounds(460,255,70,30);
			startDay.setBounds(544,255,70,30);
			startYr.setBounds(629,255,70,30);
			endMo.setBounds(460,297,70,30);
			endDay.setBounds(544,297,70,30);
			endYr.setBounds(629,297,70,30);
			budget.setBounds(460,339,300,30);
			status.setBounds(460,380,70,30);
			fengshui.setBounds(460,425,300,70);
					    
			add(pname);
			add(startMo);
			add(startDay);
			add(startYr);
			add(endMo);
			add(endDay);
			add(endYr);
			add(budget);
			add(status);
			add(fengshui);
			

		    pname.addMouseListener(this);
		    startMo.addMouseListener(this);
		    startDay.addMouseListener(this);
		    startYr.addMouseListener(this);
		    endMo.addMouseListener(this);
		    endDay.addMouseListener(this);
		    endYr.addMouseListener(this);
		    budget.addMouseListener(this);
		    status.addMouseListener(this);
		    fengshui.addMouseListener(this);
	 }
	
	public void loadImages(){
	       try{
	           background = new ImageIcon("pics/addProjbg.png").getImage();
	           save = new ImageIcon("pics/save.png").getImage();
	           cancel = new ImageIcon("pics/cancel.png").getImage();
	          
	        } catch (Exception e) { }
	       
	       repaint();
	   }
	   
	   public void paintComponent(Graphics g){
	       super.paintComponent(g);
	       Graphics2D g2d = (Graphics2D) g;
	       setForeground(Color.black);
	       setFont(new Font("Tahoma",Font.PLAIN,22));
	       g2d.drawImage(background, 0, 0, this);
	       g2d.drawString("addProject",180,140);
	       g2d.drawImage(save, 475, 590, this);
	       g2d.drawImage(cancel, 625, 590, this);
	       
	       
	       
	       
	       
	   }
	   
	   public void setGoNext(int d){
		   goNext=1;
	   }
	   
	   public int getGoNext(){
		  return goNext; 
	   }
	   
	   public void Loopy(){
			while(goNext!=1)
				repaint();
			}
	   static class AL extends MouseAdapter{
	   public void mouseClicked(MouseEvent me) {
		   PointerInfo a = MouseInfo.getPointerInfo();
		   Point b = a.getLocation();
		    x = (int) b.getX();
		    y = (int) b.getY();
		   System.out.print(y + "jjjjjjjjj");
		   System.out.print(x);
		   
		  		   	
	   }
	   
	   public void mousePressed(MouseEvent me) {
		   x = me.getX();
		   y = me.getY();
		   
		   System.out.println(x);
		   System.out.println(y);
		   
	       
	   }
	   public void mouseReleased(MouseEvent me) {
	       
	   }
	   public void mouseDragged(MouseEvent me) {
		   x = me.getX();
		   y = me.getY();
		   
		   System.out.println(x);
		   System.out.println(y);
		   
	       
	   }
	   
	   public void mouseMoved(MouseEvent me) {
		   		   
	   
	   }    
	   public void mouseEntered(MouseEvent me) {
	       
	   }
	   public void mouseExited(MouseEvent me) {
	       
	   }

	
	
}
	@Override
	public void mouseDragged(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseMoved(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}
